package 力扣日常刷题.木23一月.第15天315;

import 力扣日常刷题.ListNode;

/**
 * @author 帅小伙
 * @date 2022/3/15
 * @description
 */
public class Demo79合并两个排序链表 {

    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        if (l1 == null || l2 == null) return l1 == null ? l2 : l1;
        if(l1.val > l2.val){
            l2.next = mergeTwoLists(l1,l2.next);
            return l2;
        }else{
            l1.next = mergeTwoLists(l1.next,l2);
            return l1;
        }
    }
}
